import { LiveType } from '@/model/home/types';
import { Live } from '@/model/live/Live';
import { useInjectable } from '@/unit/hooks/use-di';
import { RedirectTo } from '@/unit/navigate-to';
import { observer } from 'mobx-react-lite';
import { useCallback, useState } from 'react';
import LiveAdd from './live-add.view';

export default observer(() => {
  const live = useInjectable(Live);

  // const [newLive, setNewLive] = useState<LiveType>(new LiveType());

  const handleCancel = useCallback(() => {
    live.setLive(new LiveType());
    RedirectTo('home');
  }, [live]);

  return (
    <LiveAdd
      live={live.live}
      explainChange={live.setExpan}
      titltChange={live.setTitle}
      handleCancel={handleCancel}
      handleCreate={live.create}
    />
  );
});
